package com.lwj.liwanjia.utils;

/**
 * Created by Administrator on 2017/4/25.
 */

import android.graphics.Color;
import android.os.CountDownTimer;
import android.widget.TextView;

/**
 * 实现倒计时的类
 */
public class TimeCount extends CountDownTimer {
    private TextView tv;

    public TimeCount(long millisInFuture, long countDownInterval, TextView tv) {
        super(millisInFuture, countDownInterval);
        this.tv = tv;
    }

    @Override
    public void onTick(long l) {
        tv.setClickable(false);
        tv.setText("(" + l / 1000 + ")秒");
        tv.setTextColor(Color.WHITE);
    }

    @Override
    public void onFinish() {
        tv.setClickable(true);
        tv.setText("重新发送");
        tv.setTextColor(Color.WHITE);
    }
}
